using ASP;
using HoWave.Common;
using HoWave.Web;
using HoWave.Web.Shop;
using System;
using System.Data;
using System.Web.Profile;
using System.Web.UI.WebControls;
public class Shop_UserControls_ShowProduct : Howave_ControlCache
{
	protected Literal ShowProductLiteral;
	private int m_num = 10;
	private string m_showType = "text";
	private string m_showFlag = "none";
	private int m_titleLength = 0;
	private string m_styleName = "";
	private string m_place = "";
	private string m_classID = "";
	private string m_openType = "_self";
	private string m_showField = "";
	private int m_sortType = -1;
	private string m_standPrice = "0";
	private string m_auction = "0";
	private string m_team = "0";
	private string m_promote = "0";
	private string m_isnew = "1";
	private string m_secondhand = "0";
	private string m_startprice = "";
	private string m_endprice = "";
	private string m_othertype = "all";
	private int m_rowNum = 1;
	private string m_productType;
	private string m_fronticon = "";
	private string m_autoUpdate = "false";
	private int m_updateCacheTime = 1;
	private string m_imgType = "ProductSmallImageUrl";
	private string m_labelName = string.Empty;
	private string m_keyValue = "";
	private string m_productIDArray = "";
	private string m_ImgUrl = "";
	protected DefaultProfile Profile
	{
		get
		{
			return (DefaultProfile)this.Context.Profile;
		}
	}
	protected global_asax ApplicationInstance
	{
		get
		{
			return (global_asax)this.Context.ApplicationInstance;
		}
	}
	public string ProductIDArray
	{
		get
		{
			return this.m_productIDArray;
		}
		set
		{
			this.m_productIDArray = value;
		}
	}
	public string KeyValue
	{
		get
		{
			return this.m_keyValue;
		}
		set
		{
			this.m_keyValue = value;
		}
	}
	public string LabelName
	{
		get
		{
			return this.m_labelName;
		}
		set
		{
			this.m_labelName = value;
		}
	}
	public string ProductImgType
	{
		get
		{
			return this.m_imgType;
		}
		set
		{
			this.m_imgType = value;
		}
	}
	public string AutoUpdate
	{
		get
		{
			return this.m_autoUpdate;
		}
		set
		{
			this.m_autoUpdate = value;
		}
	}
	public int CacheTime
	{
		get
		{
			return this.m_updateCacheTime;
		}
		set
		{
			this.m_updateCacheTime = value;
		}
	}
	public int ShowNum
	{
		get
		{
			return this.m_num;
		}
		set
		{
			this.m_num = value;
		}
	}
	public string ShowUIType
	{
		get
		{
			return this.m_showType;
		}
		set
		{
			this.m_showType = value;
		}
	}
	public string ProductType
	{
		get
		{
			return this.m_productType;
		}
		set
		{
			this.m_productType = value;
		}
	}
	public string ShowFlag
	{
		get
		{
			return this.m_showFlag;
		}
		set
		{
			this.m_showFlag = value;
		}
	}
	public string StandPrice
	{
		get
		{
			return this.m_standPrice;
		}
		set
		{
			this.m_standPrice = value;
		}
	}
	public string Auction
	{
		get
		{
			return this.m_auction;
		}
		set
		{
			this.m_auction = value;
		}
	}
	public string TeamBuy
	{
		get
		{
			return this.m_team;
		}
		set
		{
			this.m_team = value;
		}
	}
	public string PromoteBuy
	{
		get
		{
			return this.m_promote;
		}
		set
		{
			this.m_promote = value;
		}
	}
	public string StyleName
	{
		get
		{
			return this.m_styleName;
		}
		set
		{
			this.m_styleName = value;
		}
	}
	public string ProductPlace
	{
		get
		{
			return this.m_place;
		}
		set
		{
			this.m_place = value;
		}
	}
	public string ClassID
	{
		get
		{
			return this.m_classID;
		}
		set
		{
			this.m_classID = value;
		}
	}
	public int RowNums
	{
		get
		{
			return this.m_rowNum;
		}
		set
		{
			this.m_rowNum = value;
		}
	}
	public int SortType
	{
		get
		{
			return this.m_sortType;
		}
		set
		{
			this.m_sortType = value;
		}
	}
	public string OpenType
	{
		get
		{
			return this.m_openType;
		}
		set
		{
			this.m_openType = value;
		}
	}
	public string IsNew
	{
		get
		{
			return this.m_isnew;
		}
		set
		{
			this.m_isnew = value;
		}
	}
	public string SecondHand
	{
		get
		{
			return this.m_secondhand;
		}
		set
		{
			this.m_secondhand = value;
		}
	}
	public string StartPrice
	{
		get
		{
			return this.m_startprice;
		}
		set
		{
			this.m_startprice = value;
		}
	}
	public string EndPrice
	{
		get
		{
			return this.m_endprice;
		}
		set
		{
			this.m_endprice = value;
		}
	}
	public string OtherType
	{
		get
		{
			return this.m_othertype;
		}
		set
		{
			this.m_othertype = value;
		}
	}
	public int TitleLength
	{
		get
		{
			return this.m_titleLength;
		}
		set
		{
			this.m_titleLength = value;
		}
	}
	public string ShowField
	{
		get
		{
			return this.m_showField;
		}
		set
		{
			this.m_showField = value;
		}
	}
	public string FrontIcon
	{
		get
		{
			return this.m_fronticon;
		}
		set
		{
			this.m_fronticon = value;
		}
	}
	public string ImgUrl
	{
		get
		{
			return this.m_ImgUrl;
		}
		set
		{
			this.m_ImgUrl = value;
		}
	}
	protected void Page_Load(object sender, EventArgs e)
	{
		base.ControlID = this.ID;
		base.ControlAutoUpdate = this.m_autoUpdate;
		base.UpdateCacheTime = this.m_updateCacheTime;
		string str = base.GetStr();
		if (!string.IsNullOrEmpty(str) && str != "")
		{
			this.ShowProductLiteral.Text = str.Replace("<![CDATA[", "").Replace("]]>", "");
		}
	}
	public override string GetStrFromControl()
	{
		string text = Language.Get("Common/MoneryTag");
		string text2 = Language.Get("Common/MoneryUnits");
		Shop_Product shop_Product = new Shop_Product();
		DataTable dataTable = shop_Product.SearchProductList(this.m_num, 1, 0, "", this.m_keyValue, this.m_classID, this.m_sortType, this.m_place, this.m_standPrice, this.m_auction, this.m_team, this.m_promote, this.m_isnew, this.m_secondhand, this.m_startprice, this.m_endprice, this.m_othertype, this.m_productIDArray);
		string result;
		if (dataTable != null && dataTable.Rows.Count > 0)
		{
			if (dataTable.Rows.Count < this.m_num)
			{
				this.m_num = dataTable.Rows.Count;
			}
			string text3 = AppSetings.Get("InstallDir");
			string text4 = "<ul class=\"" + this.m_styleName + "\">" + Environment.NewLine;
			string text5 = "";
			if (this.m_autoUpdate == "true")
			{
				text4 = string.Concat(new string[]
				{
					"<!--缓存时间：",
					DateTime.Now.ToString(),
					"-->",
					Environment.NewLine,
					text4
				});
			}
			if (this.m_showFlag != "none")
			{
				string text6 = this.m_showFlag;
				if (text6 != null)
				{
					if (!(text6 == "hot-icon"))
					{
						if (text6 == "new-icon")
						{
							text5 = "<img src=\"" + text3 + "Images/new-icon.gif\" border=\"0\"/>";
						}
					}
					else
					{
						text5 = "<img src=\"" + text3 + "Images/hot-icon.gif\" border=\"0\"/>";
					}
				}
			}
			if (this.m_imgType != "big")
			{
				this.m_imgType = "ProductSmallImageUrl";
			}
			else
			{
				this.m_imgType = "ProductImageUrl";
			}
			for (int i = 0; i < this.m_num; i++)
			{
				string text7 = "";
				string text6;
				if (this.m_showField != "")
				{
					string[] array = this.m_showField.Split(new char[]
					{
						'|'
					});
					string[] array2 = array;
					int j = 0;
					while (j < array2.Length)
					{
						string text8 = array2[j];
						text6 = text8;
						if (text6 == null)
						{
							goto IL_2FB;
						}
						string text9;
						if (!(text6 == "LeftTime"))
						{
							if (!(text6 == "ProductPrice"))
							{
								if (!(text6 == "MarketPrice"))
								{
									if (!(text6 == "ProductType"))
									{
										goto IL_2FB;
									}
									text9 = text7;
									text7 = string.Concat(new string[]
									{
										text9,
										"<span class=\"span_",
										text8,
										"\">",
										TextFormat.GetProductType(dataTable.Rows[i][text8].ToString()),
										"</span>"
									});
								}
								else
								{
									string text10 = dataTable.Rows[i]["ProductModel"].ToString();
									if (text10 != null && text10 != "" && text10.Contains("|"))
									{
										string[] array3 = text10.Split(new char[]
										{
											'|'
										});
										text9 = text7;
										text7 = string.Concat(new string[]
										{
											text9,
											"<span class=\"span_",
											text8,
											"\">",
											text,
											array3[1],
											text2,
											"</span>"
										});
									}
								}
							}
							else
							{
								if (int.Parse(dataTable.Rows[i]["ProductType"].ToString()) == 3)
								{
									Conn conn = new Conn();
									DataTable dataTable2 = conn.GetDataTable("select * from HLShop_Product where ProductID=" + int.Parse(dataTable.Rows[i]["ProductID"].ToString()));
									switch (int.Parse(dataTable2.Rows[0]["TeamNum"].ToString()))
									{
									case 1:
										text9 = text7;
										text7 = string.Concat(new string[]
										{
											text9,
											"<span class=\"span_",
											text8,
											"\">",
											text,
											dataTable2.Rows[0]["TeamPrice1"].ToString(),
											text2,
											"</span>"
										});
										break;
									case 2:
										text9 = text7;
										text7 = string.Concat(new string[]
										{
											text9,
											"<span class=\"span_",
											text8,
											"\">",
											text,
											dataTable2.Rows[0]["TeamPrice2"].ToString(),
											text2,
											"</span>"
										});
										break;
									case 3:
										text9 = text7;
										text7 = string.Concat(new string[]
										{
											text9,
											"<span class=\"span_",
											text8,
											"\">",
											text,
											dataTable2.Rows[0]["TeamPrice3"].ToString(),
											text2,
											"</span>"
										});
										break;
									case 4:
										text9 = text7;
										text7 = string.Concat(new string[]
										{
											text9,
											"<span class=\"span_",
											text8,
											"\">",
											text,
											dataTable2.Rows[0]["TeamPrice4"].ToString(),
											text2,
											"</span>"
										});
										break;
									case 5:
										text9 = text7;
										text7 = string.Concat(new string[]
										{
											text9,
											"<span class=\"span_",
											text8,
											"\">",
											text,
											dataTable2.Rows[0]["TeamPrice5"].ToString(),
											text2,
											"</span>"
										});
										break;
									}
									dataTable2.Dispose();
								}
								else
								{
									text9 = text7;
									text7 = string.Concat(new string[]
									{
										text9,
										"<span class=\"span_",
										text8,
										"\">",
										text,
										dataTable.Rows[i][text8].ToString(),
										text2,
										"</span>"
									});
								}
							}
						}
						else
						{
							int num = (int)dataTable.Rows[i][text8];
							string text11;
							if (num > 86400)
							{
								text11 = (num / 86400).ToString() + "天";
							}
							else
							{
								int num2 = num / 3600;
								int num3 = num % 3600 / 60;
								int num4 = num % 60;
								text11 = string.Concat(new string[]
								{
									num2.ToString(),
									"时",
									num3.ToString(),
									"分",
									num4.ToString(),
									"秒"
								});
							}
							text9 = text7;
							text7 = string.Concat(new string[]
							{
								text9,
								"<span class=\"span_",
								text8,
								"\">",
								text11,
								"</span>"
							});
						}
						IL_A1F:
						j++;
						continue;
						IL_2FB:
						text9 = text7;
						text7 = string.Concat(new string[]
						{
							text9,
							"<span class=\"span_",
							text8,
							"\">",
							dataTable.Rows[i][text8].ToString(),
							"</span>"
						});
						goto IL_A1F;
					}
				}
				string text12 = dataTable.Rows[i]["ProductName"].ToString();
				if (this.m_titleLength > 0)
				{
					if (text12.Length > this.m_titleLength)
					{
						text12 = text12.Substring(0, this.m_titleLength);
					}
				}
				string text13 = dataTable.Rows[i][this.m_imgType].ToString();
				if (text13 == null | text13 == "")
				{
					text13 = text3 + "Images/nopicture.gif";
				}
				string text14 = string.Concat(new string[]
				{
					"<a href=\"",
					text3,
					"ShowProduct.aspx?ProductID=",
					dataTable.Rows[i]["ProductID"].ToString(),
					"\" target=\"",
					this.m_openType,
					"\"  title=\"",
					dataTable.Rows[i]["ProductName"].ToString(),
					"\">"
				});
				text6 = this.m_showType;
				if (text6 != null)
				{
					if (!(text6 == "text"))
					{
						if (!(text6 == "img"))
						{
							if (text6 == "imgtext")
							{
								string text9 = text4;
								text4 = string.Concat(new string[]
								{
									text9,
									"<li><b>",
									text14,
									"<img src=\"",
									this.m_ImgUrl,
									text13,
									"\" /></a></b><p><span class=\"span_title\">",
									text14,
									text12,
									"</a></span>",
									text7,
									text5,
									"</p></li>",
									Environment.NewLine
								});
							}
						}
						else
						{
							string text9 = text4;
							text4 = string.Concat(new string[]
							{
								text9,
								"<li><b>",
								text14,
								"<img src=\"",
								this.m_ImgUrl,
								text13,
								"\" /></a></b></li>",
								Environment.NewLine
							});
						}
					}
					else
					{
						if (this.m_fronticon != "")
						{
							string text9 = text4;
							text4 = string.Concat(new string[]
							{
								text9,
								"<li><img src=\"",
								text3,
								"Images/front_icon/",
								this.m_fronticon,
								"\" />&nbsp;<span class=\"span_title\">",
								text14,
								text12,
								"</a></span>",
								text7,
								text5,
								"</li>",
								Environment.NewLine
							});
						}
						else
						{
							string text9 = text4;
							text4 = string.Concat(new string[]
							{
								text9,
								"<li><span class=\"span_title\">",
								text14,
								text12,
								"</a></span>",
								text7,
								text5,
								"</li>",
								Environment.NewLine
							});
						}
					}
				}
			}
			dataTable.Dispose();
			text4 = text4 + "</ul>" + Environment.NewLine;
			result = text4;
		}
		else
		{
			result = "<div>" + Language.Get("Shop/Product/ProductWithout") + "</div>";
		}
		return result;
	}
}
